#include <QApplication>
#include <QMessageBox>
#include "mainwindowimpl.h"
#include "classes.h"
#include "cubaturs.h"

bool createConnection();

int main(int argc, char ** argv)
{
	QApplication app( argc, argv );
        if (!createConnection()) {
                QMessageBox::critical(0, qApp->tr("Cannot open database"),
                                      qApp->tr("Unable to establish a database connection.\n"
                                                      "Click Cancel to exit."), QMessageBox::Cancel);
                return 1;
            }
	MainWindowImpl win;
	win.show(); 
	app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
	return app.exec();
}

bool createConnection()
{
        QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName("waveBase");
        if (!db.open()) return false;
        return true;
}
